package leetcode.top100;

import leetcode.a_总结分布.Code06_二叉树相关拓展;
import utils.TreeNode;

/**
 * 二叉树高度。
 * 相同递归思想的题目{@link Code06_二叉树相关拓展#height()}
 * @date 2020/4/7 17:28
 */
public class Code104_二叉树深度 {
    public int maxDepth(TreeNode root) {
        if (root == null) return 0;
        return preOrder(root);
    }

    private int preOrder(TreeNode root) {
        if (root == null)
            return 0;
        int left = preOrder(root.left);
        int right = preOrder(root.right);
        return Math.max(left, right) + 1;
    }

    public static void main(String[] args) {
        System.out.println(1);
    }
}
